#include<stdio.h>

int main(){
  int ll,l,h,r,i,sl[10001];
  
  for(i=0;i<10001;i++)
    sl[i]=0;
  
  scanf("%d%d%d",&l,&h,&r);
  ll=l;
  printf("%d",ll);
  for(i=l;i<=r;i++)
    if(h>sl[i])
      sl[i]=h;
  while(scanf("%d%d%d",&l,&h,&r)!=-1)
    for(i=l;i<=r;i++)
      if(h>sl[i])
        sl[i]=h;
  for(i=ll,h=sl[ll];i<10001;i++){
    if(sl[i]!=h){
      printf(" %d ",h);
      if(sl[i]>h)
        printf("%d",i);
      else
        printf("%d",i-1);
      h=sl[i];
    }
  }
  printf(" 0\n");
  return 0;
}
